import { BaseController } from '@/api/BaseController';
import { RequestOption } from '@/common/http/types';
import { ANY_OBJECT } from '@/types/generic';
import { OnlineApiGroup } from '@/types/online/script';
import { API_CONTEXT } from '../config';

/**
 * 在线表单API分组接口
 */
export default class OnlineApiGroupController extends BaseController {
  /**
   * 列出符合过滤条件的API分组列表
   */
  static list(params: ANY_OBJECT, httpOptions?: RequestOption) {
    return super.post<OnlineApiGroup[]>(
      API_CONTEXT + '/online/onlineApiGroup/list',
      params,
      httpOptions,
    );
  }

  /**
   * 查看指定API分组对象详情
   */
  static view(params: ANY_OBJECT, httpOptions?: RequestOption) {
    return super.get<OnlineApiGroup>(
      API_CONTEXT + '/online/onlineApiGroup/view',
      params,
      httpOptions,
    );
  }

  /**
   * 新增API分组数据
   */
  static add(params: ANY_OBJECT, httpOptions?: RequestOption) {
    return super.post(API_CONTEXT + '/online/onlineApiGroup/add', params, httpOptions);
  }

  /**
   * 更新API分组数据
   */
  static update(params: ANY_OBJECT, httpOptions?: RequestOption) {
    return super.post(API_CONTEXT + '/online/onlineApiGroup/update', params, httpOptions);
  }

  /**
   * 删除API分组数据
   */
  static delete(params: ANY_OBJECT, httpOptions?: RequestOption) {
    return super.post(API_CONTEXT + '/online/onlineApiGroup/delete', params, httpOptions);
  }

  /**
   * 获取所有API分组和API列表
   */
  static listAll(params: ANY_OBJECT = {}, httpOptions?: RequestOption) {
    return super.post<{
      onlineApiGroupList: OnlineApiGroup[];
      onlineApiList: ANY_OBJECT[];
    }>(API_CONTEXT + '/online/onlineApiGroup/listAll', params, httpOptions);
  }
}
